package cn.secby.distributor.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.secby.common.log.annotation.Log;
import cn.secby.common.log.enums.BusinessType;
import cn.secby.common.security.annotation.RequiresPermissions;
import cn.secby.distributor.domain.AccountChangeHistory;
import cn.secby.distributor.service.IAccountChangeHistoryService;
import cn.secby.common.core.web.controller.BaseController;
import cn.secby.common.core.web.domain.AjaxResult;
import cn.secby.common.core.utils.poi.ExcelUtil;
import cn.secby.common.core.web.page.TableDataInfo;

/**
 * 渠道商变更历史Controller
 * 
 * @author shenkunlin
 * @date 2025-04-26
 */
@RestController
@RequestMapping("/accountChangeHistory")
public class AccountChangeHistoryController extends BaseController
{
    @Autowired
    private IAccountChangeHistoryService accountChangeHistoryService;

    /**
     * 查询渠道商变更历史列表
     */
    @RequiresPermissions("distributor:accountChangeHistory:list")
    @GetMapping("/list")
    public TableDataInfo list(AccountChangeHistory accountChangeHistory)
    {
        startPage();
        List<AccountChangeHistory> list = accountChangeHistoryService.selectAccountChangeHistoryList(accountChangeHistory);
        return getDataTable(list);
    }

    /**
     * 导出渠道商变更历史列表
     */
    @RequiresPermissions("distributor:accountChangeHistory:export")
    @Log(title = "渠道商变更历史", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AccountChangeHistory accountChangeHistory)
    {
        List<AccountChangeHistory> list = accountChangeHistoryService.selectAccountChangeHistoryList(accountChangeHistory);
        ExcelUtil<AccountChangeHistory> util = new ExcelUtil<AccountChangeHistory>(AccountChangeHistory.class);
        util.exportExcel(response, list, "渠道商变更历史数据");
    }

    /**
     * 获取渠道商变更历史详细信息
     */
    @RequiresPermissions("distributor:accountChangeHistory:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(accountChangeHistoryService.selectAccountChangeHistoryById(id));
    }

    /**
     * 新增渠道商变更历史
     */
    @RequiresPermissions("distributor:accountChangeHistory:add")
    @Log(title = "渠道商变更历史", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AccountChangeHistory accountChangeHistory)
    {
        return toAjax(accountChangeHistoryService.insertAccountChangeHistory(accountChangeHistory));
    }

    /**
     * 修改渠道商变更历史
     */
    @RequiresPermissions("distributor:accountChangeHistory:edit")
    @Log(title = "渠道商变更历史", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AccountChangeHistory accountChangeHistory)
    {
        return toAjax(accountChangeHistoryService.updateAccountChangeHistory(accountChangeHistory));
    }

    /**
     * 删除渠道商变更历史
     */
    @RequiresPermissions("distributor:accountChangeHistory:remove")
    @Log(title = "渠道商变更历史", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids)
    {
        return toAjax(accountChangeHistoryService.deleteAccountChangeHistoryByIds(ids));
    }
}
